﻿using Heng.Elements.Core.Model.Infrastructure.Messages;
using Heng.Elements.Core.Model.Infrastructure.Repositories;
using Heng.Elements.Core.Model.Infrastructure.Services;
using Heng.Elements.ERD.Model.Entities;
using Heng.Elements.ERD.Model.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Heng.Elements.ERD.Model.Services
{
    public class DomainEntityService : EntityServiceBase<DomainEntity>
    {
        public DomainEntityService(EntityRepositoryContext ctx)
            :base(ctx)
        {
        }

        public ServiceResponse<IEnumerable<DomainEntity>> GetByDomain(long domainId)
        {
            var response = ExecInContext<IEnumerable<DomainEntity>>((ctx, res) =>
                {
                    var repo = ctx.GetRepository<IDomainEntityRepository>();
                    var entities = repo.GetByDomain(domainId);
                    return entities;
                });

            return response;
        }
    }
}
